package com.ruoyi.common.mapper;

import com.ruoyi.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UtilsMapper {

    /**
     * 条件查询当前部门所有的子部门
     * @param sysDept
     * @return
     */
    @Select("<script>" +
            "select * from sys_dept" +
            "where 1=1 " +
            "<if test='sysDept.deptId !=null' > and parent_id = #{sysDept.deptId} </if>" +
            "</script>")
    List<SysDept> getDept(@Param("sysDept") SysDept sysDept);


    @Select("<script>" +
            "select * from sys_dept " +
            "where 1=1 " +
            "<if test='sysDept.deptId !=null' > and dept_id = #{sysDept.deptId} </if>" +
            "<if test='sysDept.parentId !=null' > and parent_id = #{sysDept.parentId} </if>" +
            "</script>")
    SysDept getDeptList(@Param("sysDept") SysDept sysDept);

    @Select("<script>" +
            "select * from sys_dept " +
            "where 1=1 " +
            "<if test='sysDept.deptId !=null' > and dept_id = #{sysDept.deptId} </if>" +
            "<if test='sysDept.parentId !=null' > and parent_id = #{sysDept.parentId} </if>" +
            "</script>")
    List<SysDept> getAllDept(@Param("sysDept") SysDept sysDept);
}
